import axios, { AxiosError } from 'axios'
import { useUserStoreWithOut } from '@/store/modules/user'
const userStore = useUserStoreWithOut()

axios.interceptors.request.use(
  function (config) {
    // Do something before request is sent
    config.headers['Token'] = userStore.zjToken ?? ''
    config.headers['Content-Type'] = 'multipart/form-data'
    return config
  },
  function (error) {
    // Do something with request error
    return Promise.reject(error)
  }
)

// Add a response interceptor
axios.interceptors.response.use(
  function (response) {
    // Do something with response data
    return response.data
  },
  function (error) {
    // Do something with response error
    return Promise.reject(error)
  }
)
export default axios
